public class AssignStmt {
	String id ;
	String ao;
	Expression exp;
	String sm;
	int lineNum;
	int charPos;
	
	public AssignStmt ( String id, String ao, Expression exp, String sm, int line, int charP){
		this.id = id;
		this.ao = ao;
		this.exp = exp;
		this.sm = sm;
		this.lineNum = line;
		this.charPos = charP;
	}
	public String toString(){
		String ret = "AssignStmt "+ id +"\n";

		String s = "";

		if (exp != null) {
			s +=  exp.toString();
		}
		
		return ret+s;
	}
	public void check() throws SemanticException {
		SymbolTable table = SymbolTable.getInstance();
		if (!table.contains(id) ) {
			throw new SemanticException("Semantic Error at line " + this.lineNum + " char " + this.charPos + ":\nThe identifier '" + id + "' hasn't been declared before.\nIn: " + Parser.getLineOfCode(this.lineNum));
		}
		Type t = table.get(id).type;
		if (exp != null) {
			exp.check(t);
//			if (exp.cae.ee.ae.me.pe.nm != null && table.get(id).type.type != "int"
//				&& exp.cae.ee.ae.me.pe.nm != null && table.get(id).type.type != "float") {
//				throw new SemanticException("Variable " + id + " can't hold a value of this type" + " " + id);	
//			} else if (exp.cae.ee.ae.me.pe.st != null && table.get(id).type.type != "String") {
//				throw new SemanticException("Variable " + id + " can't hold a value of this type" + " " + id);
//			} else if (exp.cae.ee.ae.me.pe.bl != null && table.get(id).type.type != "boolean") {
//				throw new SemanticException("Variable " + id + " can't hold a value of this type" + " " + id);
//			}
		}
	}
}
